﻿// // ******************************************************************
// //       /\ /|       @file       MappConfigure.cs
// //       \ V/        @brief      await29
// //       | "")       @author     Await, 285283010@qq.com
// //       /  |
// //      /  \\        @Modified   2024-11-08 20:11
// //    *(__\_\        @Copyright  Copyright (c) , 2024-11-08 20:11 Await
// // ******************************************************************

using AutomaticSubtitles.Contracts.Dto;
using AutomaticSubtitles.Service.DataAccess.Model;
using AutomaticSubtitles.Service.Infrastructure.Localization;

namespace AutomaticSubtitles.Service.DataAccess.MappProfile;

public class MappConfigure
{
    public static void Configure()
    {
        TypeAdapterConfig.GlobalSettings.Default.NameMatchingStrategy(NameMatchingStrategy.Flexible);

        TypeAdapterConfig.GlobalSettings.Default.PreserveReference(true);

        var localizationOptions = LocalizationManager.GetLocalizationOptions().ToList();
        //LanguageDto - LanguageVo 转换
        TypeAdapterConfig<Auto_Language, LanguageDto>.NewConfig()
            // .Map(dest => dest.Name, src => src.Key.FindByAttribute<GlobalVariableEnumConfiguration.LanguageEnum, DescriptionAttribute>()!.Description);
            .Map(dest => dest.Name, src => localizationOptions.FirstOrDefault(x => x.Value == src.Key)!.Name);
    }
}